package cn.cs.service;

import cn.cs.mapper.AfterOrderMapper;
import cn.cs.mapper.FaultTypeMapper;
import cn.cs.pojo.AfterOrder;
import cn.cs.pojo.AppOrderConcelcause;
import cn.cs.pojo.FaultType;
import cn.cs.pojo.ServiceType;
import org.apache.ibatis.annotations.Param;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
public class RestFaultTypeService {

    @Resource
    private FaultTypeMapper faultTypeMapper;

    @RequestMapping(value = "/getConcelcause", method = RequestMethod.POST)
    public List<AppOrderConcelcause> getConcelcause()throws Exception{
        return faultTypeMapper.getConcelcause();
    }

    @RequestMapping(value = "/getFaultCategory", method = RequestMethod.POST)
    public List<ServiceType> getFaultCategory()throws Exception{
        return faultTypeMapper.getFaultCategory();
    }

    @RequestMapping(value = "/getTypeTree", method = RequestMethod.POST)
    public List<FaultType> getTypeTree(){
        return faultTypeMapper.getTypeTree();
    }

    @RequestMapping(value = "/getFaultType", method = RequestMethod.POST)
    public List<FaultType> getFaultType(){
        return faultTypeMapper.getFaultType();
    }

    @RequestMapping(value = "/getFaultTypeTree", method = RequestMethod.POST)
    public List<FaultType> getFaultTypeTree(){
        return faultTypeMapper.getFaultTypeTree();
    }

    @RequestMapping(value = "/getFaultTypeByPid", method = RequestMethod.POST)
    public List<Map<String,Object>> getFaultTypeByPid(@RequestParam("id") String id){
        return faultTypeMapper.getFaultTypeByPid(id);
    }

    @RequestMapping(value = "/getTwoFaultCategory", method = RequestMethod.POST)
    public List<FaultType> getTwoFaultCategory(@RequestParam("level") String level)throws Exception{
        return faultTypeMapper.getTwoFaultCategory(level);
    }

    @RequestMapping(value = "/getFaultTypeById", method = RequestMethod.POST)
    public List<Map<String,Object>> getFaultTypeById(@RequestParam("parentId") String parentId)throws Exception{
        return faultTypeMapper.getFaultTypeById(parentId);
    }

    @RequestMapping(value = "/getFaultTypeByParentId", method = RequestMethod.POST)
    public List<Map<String,Object>> getFaultTypeByParentId(@RequestParam("parentId") String parentId)throws Exception{
        return faultTypeMapper.getFaultTypeByParentId(parentId);
    }

    @RequestMapping(value = "/getFaultTypeListByMap", method = RequestMethod.POST)
    public List<FaultType> getFaultTypeListByMap(@RequestBody Map<String, Object> param)throws Exception{
        return faultTypeMapper.getFaultTypeListByMap(param);
    }

    @RequestMapping(value = "/getFaultTypeCountByMap", method = RequestMethod.POST)
    public Integer getFaultTypeCountByMap(@RequestBody Map<String, Object> param)throws Exception{
        return faultTypeMapper.getFaultTypeCountByMap(param);
    }

    @RequestMapping(value = "/getServiceTypeListByMap", method = RequestMethod.POST)
    public List<ServiceType> getServiceTypeListByMap(@RequestBody Map<String, Object> param)throws Exception{
        return faultTypeMapper.getServiceTypeListByMap(param);
    }

    @RequestMapping(value = "/getServiceTypeCountByMap", method = RequestMethod.POST)
    public Integer getServiceTypeCountByMap(@RequestBody Map<String, Object> param)throws Exception{
        return faultTypeMapper.getServiceTypeCountByMap(param);
    }

    @RequestMapping(value = "/addFaultType", method = RequestMethod.POST)
    public Integer addFaultType(@RequestBody FaultType faultType)throws Exception{
        return faultTypeMapper.insertFaultType(faultType);
    }

    @RequestMapping(value = "/modifyFaultType", method = RequestMethod.POST)
    public Integer modifyFaultType(@RequestBody FaultType faultType)throws Exception{
        return faultTypeMapper.updateFaultType(faultType);
    }

    @RequestMapping(value = "/deleteFaultTypeById", method = RequestMethod.POST)
    public Integer deleteFaultTypeById(@RequestParam("id") String id)throws Exception{
        return faultTypeMapper.deleteFaultTypeById(id);
    }

    @RequestMapping(value = "/deleteServiceTypeById", method = RequestMethod.POST)
    public Integer deleteServiceTypeById(@RequestParam("id") String id)throws Exception{
        return faultTypeMapper.deleteServiceTypeById(id);
    }

    @RequestMapping(value = "/addServiceType", method = RequestMethod.POST)
    public Integer addServiceType(@RequestBody ServiceType serviceType)throws Exception{
        return faultTypeMapper.insertServiceType(serviceType);
    }

    @RequestMapping(value = "/modifyServiceType", method = RequestMethod.POST)
    public Integer modifyServiceType(@RequestBody ServiceType serviceType)throws Exception{
        return faultTypeMapper.updateServiceType(serviceType);
    }

    @RequestMapping(value = "/getFaultTypeByIdOnlyOne", method = RequestMethod.POST)
    public FaultType getFaultTypeByIdOnlyOne(@RequestParam("id") String id)throws Exception{
        return faultTypeMapper.getFaultTypeByIdOnlyOne(id);
    }

    @RequestMapping(value = "/getFaultTypeByOnlyId", method = RequestMethod.POST)
    public FaultType getFaultTypeByOnlyId(@RequestParam("id") String id)throws Exception{
        return faultTypeMapper.getFaultTypeByOnlyId(id);
    }

    @RequestMapping(value = "/getServiceTypeList", method = RequestMethod.POST)
    public List<ServiceType> getServiceTypeList(){
        return faultTypeMapper.getServiceTypeList();
    }

    @RequestMapping(value = "/getFaultTypeEntityByParentId", method = RequestMethod.POST)
    public List<FaultType> getFaultTypeEntityByParentId(@RequestBody Map<String, Object> param){
        return faultTypeMapper.getFaultTypeEntityByParentId(param);
    }

    @RequestMapping(value = "/getServiceTypeById", method = RequestMethod.POST)
    public ServiceType getServiceTypeById(@RequestParam("id") String id)throws Exception{
        return faultTypeMapper.getServiceTypeById(id);
    }


}
